﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MatrixGame
{
	public partial class MainForm : Form
	{
		public MainForm()
		{
			InitializeComponent();
		}

		private void SourceFieldControl_FieldClicked(object sender, FieldClickedEventArgs e)
		{
			e.InvertCell();
			Apply();
		}

		private void TransformationFieldControl_FieldClicked(object sender, FieldClickedEventArgs e)
		{
			e.InvertCell();
			Apply();
		}

		public void Apply()
		{
			ResultFieldControl.Field = new Field(SourceFieldControl.Field);
			foreach (var FieldCoordinates in TransformationFieldControl.Field.GetBlackCells())
			{
				ResultFieldControl.Field.Invert5Cross(FieldCoordinates.Row, FieldCoordinates.Column);
			}
			ResultFieldControl.Refresh();
		}

		private void ResultFieldControl_FieldClicked(object sender, FieldClickedEventArgs e)
		{
			TransformationFieldControl.Field.InvertCell(e.Coordinates.Row, e.Coordinates.Column);
			Apply();
			TransformationFieldControl.Refresh();
		}
	}
}
